<?php
namespace App\Controllers;
use App\Requests\PhoneRequest;
use App\Requests\UserCodeLoginRequest;
use App\Requests\UserLoginRequest;
use App\Services\UserService;
use App\Services\UserService as Service;
use Framework\BaseController;

class LoginController extends BaseController
{
    /**
     * @var Service
     */
    private $UserService;

    public function __construct(Service $service)
    {
        $this->UserService = $service;
    }

    /**用户账号密码登录
     * @param UserLoginRequest $request
     */
    public function login(UserLoginRequest $request)
    {
        $phone = $request->phone();
        $password = $request->password();

        $info = $this->UserService->Login($phone, $password);

        $this->retSuccess($info);
    }

    public function codeLogin(UserCodeLoginRequest $request)
    {
        $phone = $request->phone();
        $code = $request->code();
        $info = $this->UserService->codeLogin($phone, $code);

        $this->retSuccess($info);
    }



}
